

function delAll(ctrl){
    //alert(111);
	var ids='';
    var controller="http://localhost/project/fly/index.php/Admin/"+ctrl+"/delAll";
	//var controller = "{:U('admin/"+ctrl+"/del')}";
    for(var i=0;i<$('.index').length;i++){
        if($('.index').eq(i).is(':checked')){
            ids+=$('.index').eq(i).val();
            ids+=',';
        }
    }
    layer.confirm('确定要删除吗？',function(index){
        $.ajax({
            url: controller,
            type: 'post',
            dataType: 'json',
            data: {ids: ids},
        })
        .done(function(res) {
            if (res.error==0) {
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }else{
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
    });
}


function delOne(ctrl,id){
    var id = id;
    var controller="http://localhost/project/fly/index.php/Admin/"+ctrl+"/del";
    layer.confirm('确定要删除吗？',function(index){
        $.ajax({
            url: controller,
            type: 'post',
            dataType: 'json',
            data: {id: id},
        })
        .done(function(res) {
            if (res.error==0) {
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }else{
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
    });
}

function recoverOne(ctrl,id){
    var id = id;
    var controller="http://localhost/project/fly/index.php/Admin/"+ctrl+"/recover";
    layer.confirm('确定要删除吗？',function(index){
        $.ajax({
            url: controller,
            type: 'post',
            dataType: 'json',
            data: {id: id},
        })
        .done(function(res) {
            if (res.error==0) {
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }else{
                layer.alert(res.info ,{icon: 1}, function(){
                    layer.closeAll();
                    location.reload();
                });
            }
        })
        .fail(function() {
            console.log("error");
        })
    });
}